//https://leetcode.cn/problems/backspace-string-compare/

public:
    bool backspaceCompare(string s, string t) {
        return changestr(s) == changestr(t);

    }

    string changestr(string& s)
    {
        string ret;
        for (auto ch : s)
        {
            if (ch == '#')
            {
                if (ret != "")
                {
                    ret.pop_back();
                }
            }
            else
                ret += ch;
        }

        return ret;
    }
};